import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from './components/login.vue'
import Home from './components/home.vue'
import welcome from './components/welcome.vue'
import users from './components/users/users.vue'
import rights from './components/power/Rights'
import roles from './components/power/Roles'


Vue.use(VueRouter)

// 链式编程报错解决方法 a地址跳转a地址的解决方案
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default new VueRouter({
    routes: [
        //重定向
        { path: '/', redirect: '/login' },

        { path: '/login', component: Login },
        {
            path: '/home', component: Home, redirect: '/welcome', children: [
                { path: '/welcome', component: welcome },
                { path: '/users', component: users },
                { path: '/rights', component: rights },
                { path: '/roles', component: roles }
            ]
        }
    ]
})